home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1199 / 1624 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  6.4 KB

  1. Subject: fselect patch... (repost)
  2. Date: Thu, 23 Jun 94 9:33:18 +0200
  3. From: Torsten Scherer <itschere@techfak.uni-bielefeld.de>
  4.  
  5.  Huhu!
  6.  
  7.  I've been reported that my patch for exceptional conditions has had no
  8. `tabs' in it. I must admit that I've only noticed it when I've read my own
  9. mail from the list and assume that I've had some problems with my
  10. communication program.
  11.  
  12.  So, for those of you who felt disturbed by this, here it is again, with
  13. the `better' value for FIOEXCEPT and a bit nicer, I hope... :-)
  14.  
  15. ciao,
  16. TeSche
  17. --
  18. Torsten Scherer (TeSche, Schiller...)
  19. Faculty of Technology, University of Bielefeld, Germany, Europe, Earth...
  20. | Use any of "finger itschere@129.70.131.2-15" for adresses and more.    |
  21. | Last updated: 14. April 1994.                        |
  22.  
  23.  
  24. --- file.h.orig    Sun Jun 19 17:54:16 1994
  25. +++ file.h    Thu Jun 23 09:20:02 1994
  26. @@ -340,6 +340,7 @@
  27.  #define FSTAT        (('F'<< 8) | 0)        /* handled by kernel */
  28.  #define FIONREAD    (('F'<< 8) | 1)
  29.  #define FIONWRITE    (('F'<< 8) | 2)
  30. +#define FIOEXCEPT    (('F'<< 8) | 5)
  31.  #define TIOCGETP    (('T'<< 8) | 0)
  32.  #define TIOCSETN    (('T'<< 8) | 1)
  33.  #define TIOCGETC    (('T'<< 8) | 2)
  34. --- dosfile.c.orig    Sun Jun 19 17:54:26 1994
  35. +++ dosfile.c    Sun Jun 19 17:54:24 1994
  36. @@ -954,11 +954,11 @@
  37.   * integers containing bitmasks that describe which file descriptors
  38.   * we're interested in. These masks are changed to represent which
  39.   * file descriptors actually have data waiting (rfd), are ready to
  40. - * output (wfd), or have exceptional conditions (xfd -- currently
  41. - * ignored). If timeout is 0, fselect blocks until some file descriptor
  42. - * is ready; otherwise, it waits only "timeout" milliseconds.
  43. - * Return value: number of file descriptors that are available for
  44. - * reading/writing; or a negative error number.
  45. + * output (wfd), or have exceptional conditions (xfd). If timeout is 0,
  46. + * fselect blocks until some file descriptor is ready; otherwise, it
  47. + * waits only "timeout" milliseconds. Return value: number of file
  48. + * descriptors that are available for reading/writing; or a negative
  49. + * error number.
  50.   */
  51.  
  52.  /* helper function for time outs */
  53. @@ -974,7 +974,7 @@
  54.      unsigned timeout;
  55.      long *rfdp, *wfdp, *xfdp;
  56.  {
  57. -    long rfd, wfd;
  58. +    long rfd, wfd, xfd;
  59.      long mask, bytes;
  60.      int i, count;
  61.      FILEPTR *f;
  62. @@ -982,9 +982,6 @@
  63.      TIMEOUT *t;
  64.      short sr;
  65.  
  66. -    if (xfdp)
  67. -        *xfdp = 0;
  68. -
  69.      if (rfdp) {
  70.          rfd = *rfdp; *rfdp = 0;
  71.      }
  72. @@ -995,14 +992,19 @@
  73.      }
  74.      else
  75.          wfd = 0;
  76. +    if (xfdp) {
  77. +        xfd = *xfdp; *xfdp = 0;
  78. +    }
  79. +    else
  80. +        xfd = 0;
  81.  
  82. -    TRACE(("Fselect(%u, %lx, %lx)", timeout, rfd, wfd));
  83. +    TRACE(("Fselect(%u, %lx, %lx, %lx)", timeout, rfd, wfd, xfd));
  84.      p = curproc;            /* help the optimizer out */
  85.  
  86.      /* first, validate the masks */
  87.      mask = 1L;
  88.      for (i = 0; i < MAX_OPEN; i++) {
  89. -        if ( ((rfd & mask) || (wfd & mask)) && !(p->handle[i]) ) {
  90. +        if ( ((rfd & mask) || (wfd & mask) || (xfd & mask)) && !(p->handle[i]) ) {
  91.              DEBUG(("Fselect: invalid handle: %d", i));
  92.              return EIHNDL;
  93.          }
  94. @@ -1044,6 +1046,17 @@
  95.                  *wfdp |= mask;
  96.              }
  97.          }
  98. +        if (xfd & mask) {
  99. +            f = p->handle[i];
  100. +/* tesche: anybody worried about using O_RDWR for exceptional data? ;) */
  101. +            if ((*f->dev->select)(f, (long)p, O_RDWR) == 1) {
  102. +/*  tesche: for old device drivers, which don't understand this
  103. + * call, this will never be true and therefore won't disturb us here.
  104. + */
  105. +                count++;
  106. +                *xfdp |= mask;
  107. +            }
  108. +        }
  109.          mask = mask << 1L;
  110.      }
  111.  
  112. @@ -1106,6 +1119,20 @@
  113.                      }
  114.                  }
  115.              }
  116. +            if (xfd & mask) {
  117. +                f = p->handle[i];
  118. +                if (f) {
  119. +/*  tesche: since old device drivers won't understand this call,
  120. + * we set up `no exceptional condition' as default.
  121. + */
  122. +                    bytes = 0L;
  123. +                    (void)(*f->dev->ioctl)(f, FIOEXCEPT,&bytes);
  124. +                    if (bytes > 0) {
  125. +                    *xfdp |= mask;
  126. +                    count++;
  127. +                    }
  128. +                }
  129. +            }
  130.              mask = mask << 1L;
  131.          }
  132.      }
  133. @@ -1125,6 +1152,11 @@
  134.              if (f)
  135.                  (*f->dev->unselect)(f, (long)p, O_WRONLY);
  136.          }
  137. +        if (xfd & mask) {
  138. +            f = p->handle[i];
  139. +            if (f)
  140. +                (*f->dev->unselect)(f, (long)p, O_RDWR);
  141. +        }
  142.          mask = mask << 1L;
  143.      }
  144.  
  145. --- biosfs.c.orig    Mon Jun 20 14:28:52 1994
  146. +++ biosfs.c    Mon Jun 20 14:33:36 1994
  147. @@ -1090,11 +1090,12 @@
  148.      FILEPTR *f; int mode; void *buf;
  149.  {
  150.      UNUSED(f);
  151. -    if (mode == FIONREAD) {
  152. +    if (mode == FIONREAD)
  153.          *((long *)buf) = 0;
  154. -    }
  155.      else if (mode == FIONWRITE)
  156.          *((long *)buf) = 1;
  157. +    else if (mode == FIOEXCEPT)
  158. +        *((long *)buf) = 0;
  159.      else
  160.          return EINVFN;
  161.      return 0;
  162. @@ -1130,8 +1131,10 @@
  163.      int mode;
  164.  {
  165.      UNUSED(f); UNUSED(p);
  166. -    UNUSED(mode);
  167. -    return 1;    /* we're always ready to read/write */
  168. +    if ((mode == O_RDONLY) || (mode == O_WRONLY))
  169. +        return 1;    /* we're always ready to read/write */
  170. +
  171. +    return 0;    /* other things we don't care about */
  172.  }
  173.  
  174.  void ARGS_ON_STACK 
  175. @@ -1339,6 +1342,9 @@
  176.          else
  177.              *r = 0;
  178.          break;
  179. +    case FIOEXCEPT:
  180. +        *r = 0;
  181. +        break;
  182.      case TIOCFLUSH:
  183.          {
  184.          int oldmap;
  185. @@ -1878,6 +1884,10 @@
  186.          if (r < 0) r += MOUSESIZ;
  187.          *((long *)buf) = r;
  188.      }
  189. +    else if (mode == FIONWRITE)
  190. +        *((long *)buf) = 0;
  191. +    else if (mode == FIOEXCEPT)
  192. +        *((long *)buf) = 0;
  193.      else
  194.          return EINVFN;
  195.      return 0;
  196. @@ -1891,8 +1901,12 @@
  197.  {
  198.      UNUSED(f);
  199.  
  200. -    if (mode != O_RDONLY)
  201. -        return 1;    /* we can always take output :-) */
  202. +    if (mode != O_RDONLY) {
  203. +        if (mode == O_WRONLY)
  204. +            return 1;    /* we can always take output :-) */
  205. +        else
  206. +            return 0;    /* but don't care for anything else */
  207. +    }
  208.  
  209.      if (mousetail - mousehead)
  210.          return 1;    /* input waiting already */
  211. --- fasttext.c.orig    Mon Jun 20 14:28:38 1994
  212. +++ fasttext.c    Mon Jun 20 14:30:48 1994
  213. @@ -1322,6 +1322,9 @@
  214.      else if (mode == FIONWRITE) {
  215.              *r = 1;
  216.      }
  217. +    else if (mode == FIOEXCEPT) {
  218. +            *r = 0;
  219. +    }
  220.      else if (mode == TIOCFLUSH) {
  221.  /* BUG: this should flush the input/output buffers */
  222.          return 0;
  223. --- pipefs.c.orig    Mon Jun 20 14:35:42 1994
  224. +++ pipefs.c    Mon Jun 20 14:37:16 1994
  225. @@ -782,6 +782,9 @@
  226.              }
  227.              *((long *) buf) = r;
  228.              break;
  229. +    case FIOEXCEPT:
  230. +            *((long *) buf) = 0;
  231. +            break;
  232.      case F_SETLK:
  233.      case F_SETLKW:
  234.          lck = (struct flock *)buf;
  235. --- procfs.c.orig    Mon Jun 20 14:37:30 1994
  236. +++ procfs.c    Mon Jun 20 14:38:08 1994
  237. @@ -693,6 +693,9 @@
  238.      case FIONWRITE:
  239.          *((long *)buf) = 1L;    /* we're always ready for i/o */
  240.          return 0;
  241. +    case FIOEXCEPT:
  242. +        *((long *)buf) = 0L;
  243. +        return 0;
  244.      default:
  245.          DEBUG(("procfs: bad Fcntl command"));
  246.      }
  247. --- tosfs.c.orig    Mon Jun 20 14:34:46 1994
  248. +++ tosfs.c    Mon Jun 20 14:35:04 1994
  249. @@ -1314,6 +1314,9 @@
  250.      case FIONWRITE:
  251.          *((long *)buf) = 1;
  252.          return 0;
  253. +    case FIOEXCEPT:
  254. +        *((long *)buf) = 0;
  255. +        return 0;
  256.      case F_SETLK:
  257.      case F_SETLKW:
  258.      case F_GETLK:
  259.